<template>
  <div class="usercenter">
    <div class='txt'>待开发...</div>
    <!-- <div @click="login">登录</div> -->
    <TabBar actIndex="3"></TabBar>
  </div>
</template>
<script>
import TabBar from "../../compoment/tebBar.vue";
export default {
  components: {
    TabBar,
  },
  data() {
    return {};
  },
  mounted() {
    // console.log('11', wx.getExtConfig());
    // this.getExtConfig()
    // this.getUserInfo()
    this.auths()
  },
  methods: {
    getExtConfig() {
      if (wx.getExtConfig)
        wx.getExtConfig({
          success: (res) => {
            console.log('获取第三方数据', res.extConfig);
          }
        })
    },

    /**
     * @use 登录
     */
    login() {
      wx.login({
        success: res => {
          const { code } = res
          console.log('code', code);
          // 获取session_key和openid0.0.0.
          // wx.request({
          //   url: 'https://api.weixin.qq.com/sns/jscode2session',
          //   data: {
          //     js_code: res.code,
          //     grant_type: 'authorization_code',
          //     appid: 'wxe930a2353359473d',
          //     secret: '949d1u22cbffbrarjh182eig55721odj'
          //   },
          //   header: {
          //     'content-type': 'application/x-www-form-urlencoded'
          //   },
          //   success: res => {
          //     console.log(res);
          //     wx.setStorageSync('token', res.data.session_key);
          //     wx.navigateTo({
          //       url: '/pages/index/index'
          //     })
          //   }
          // })
        }
      })
    },

    getUserInfo() {
      wx.getUserInfo({
        withCredentials: false,
        success: res => {

          console.log(res);
        }
      })
    },

    auths() {
      wx.getSetting({
        success(res) {
          console.log('11', res.authSetting)
          if (res.authSetting['scope.userInfo']) {
            wx.authorize({
              scope: 'scope.userInfo',
              success() {
                console.log('授权成功');
                wx.getUserProfile({
                  desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
                  success: (res) => {
                   console.log('获取用户信息',res);
                  }
                })
              }

            })
          }
        }
      })
    }
  },
};
</script>
<style lang="less">
@import url("./style/index.less");
</style>
